package cn.trigram.mgb;

import org.apache.commons.lang3.StringUtils;
import org.mybatis.generator.internal.util.JavaBeansUtil;

public class RenameUtil {

  public static String renameColumnName(String columnName) {

    if (StringUtils.startsWithIgnoreCase(columnName, "l_")) {
      columnName = StringUtils.removeStartIgnoreCase(columnName, "l_");
    } else if (StringUtils.startsWithIgnoreCase(columnName, "vc_")) {
      columnName = StringUtils.removeStartIgnoreCase(columnName, "vc_");
    } else if (StringUtils.startsWithIgnoreCase(columnName, "c_")) {
      columnName = StringUtils.removeStartIgnoreCase(columnName, "c_");
    } else if (StringUtils.startsWithIgnoreCase(columnName, "en_")) {
      columnName = StringUtils.removeStartIgnoreCase(columnName, "en_");
    } else if (StringUtils.startsWithIgnoreCase(columnName, "i_")) {
      columnName = StringUtils.removeStartIgnoreCase(columnName, "i_");
    } else if (StringUtils.startsWithIgnoreCase(columnName, "dt_")) {
      columnName = StringUtils.removeStartIgnoreCase(columnName, "dt_");
    } else if (StringUtils.startsWithIgnoreCase(columnName, "s_")) {
      columnName = StringUtils.removeStartIgnoreCase(columnName, "s_");
    }
    return columnName;
  }

  public static String regenerateJavaProperty(String columnName) {

    return renameColumnName(JavaBeansUtil.getCamelCaseString(renameColumnName(columnName), false));
  }

}
